function getCookie(b) {
    var a = document.cookie.match(new RegExp("(^| )" + b + "=([^;]*)(;|$)"));
    return a != null ? unescape(a[2]) : null;
}

function setCookie(b, d, a, e) {
    if (a) var c = a; else var c = 90;
    var f = new Date;
    f.setTime(f.getTime() + c * 24 * 60 * 60 * 1e3), b += "=" + escape(d) + ";expires=" + f.toGMTString(), e && (b += "; path=" + e), document.cookie = b;
}

function setCookieBydomain(b, e, a, f) {
    if (a) var d = a; else var d = 90;
    var g = new Date;
    g.setTime(g.getTime() + d * 24 * 60 * 60 * 1e3);
    var c = b + "=" + escape(e) + ";path=" + f + ";expires=" + g.toGMTString();
    c += ";domain=" + cookie_domain, document.cookie = c;
}

function hide_landingpage() {
    jQuery("#guideBox").hide(), jQuery("html").css("overflow", ""), jQuery("html").removeClass("win");
}

function show_landingpage() {
    setTimeout(hide_landingpage, 25e3);
    var a = getCookie("landingpage"), b = window.location.pathname;
    if (b == "/wp-login.php" || b == "/") if (a == "" || a == null) jQuery("html, body").animate({
        "scrollTop": 0
    }, 0), jQuery("html").css("overflow", "hidden"), jQuery("html").addClass("win"), jQuery("#guideBox").show(), setCookieBydomain("landingpage", 1, 730, "");
}

function tooltipBuyUrlShow(a) {
    $tooltip = $("#" + a + ">div"), $tooltip.attr("class", "tooltipBuyUrl"), $tooltip.show();
}

function tooltipBuyUrlHide(a) {
    $tooltip = $("#" + a + ">div"), $tooltip.hide();
}

function cancle_quote() {
    $("#comment").addClass("brack");
    var b = $.trim($("#comment").val()), a = "为维护良好的讨论环境，请勿在留言中发布政治话题、买卖返券、加价转让、人身攻击等内容。";
    b == "" && $("#comment").val(a), $("#comment_parent").attr("value", 0);
    var c = document.getElementById("cdc_quote_to");
    c && c.parentNode.removeChild(c);
}

function change_show_mode(a, b) {
    return $thisTag = $("#" + b), a == "showDetails" ? ($("#" + b + " .p_excerpt .my_add_text").hide(), $thisTag.parents(".perContentBox").find(".conBox").removeClass("excerptBox").addClass("show_all_content"), $thisTag.parents(".perContentBox").find(".conBox img").each(function() {
        $(this).attr("src", $(this).attr("data-original"));
    }), $thisTag.children("div").children(".showDetails").css("display", "none"), $thisTag.children("div").children(".closeDetails").css("display", "block")) : ($("#" + b + " .p_excerpt .my_add_text").show(), $thisTag.parents(".perContentBox").find(".conBox").addClass("excerptBox").removeClass("show_all_content"), $("html,body").animate({
        "scrollTop": $thisTag.parents(".perContentBox").offset().top - 40
    }, "10"), $thisTag.children("div").children(".showDetails").css("display", ""), $thisTag.children("div").children(".closeDetails").css("display", "none")), !1;
}

function changePaper() {
    $("#slide_perv") && $("#slide_perv").css("opacity", .3), $("#slide_next") && $("#slide_next").css("opacity", .3), $("#slide_bg") && $("#slide_bg").height($("#slide_text").height()), go_switch && (slideInterval = window.setInterval("next_img()", tt), $("#slide_wrapper").hover(function() {
        $("#slide_perv").css("opacity", .8), $("#slide_next").css("opacity", .8), go_switch = !1, clearInterval(slideInterval);
    }, function() {
        $("#slide_perv").css("opacity", .3), $("#slide_next").css("opacity", .3), go_switch = !0, slideInterval = window.setInterval("next_img()", tt);
    }));
}

function pre_img() {
    nn--, nn < 1 && (nn = total_num), setFocus(nn);
}

function next_img() {
    nn++, nn > total_num && (nn = 1), setFocus(nn);
}

function setFocus(a) {
    nn = a, $("#panel").find("ul li").css({
        "display": "none"
    }), $("#panel").find("#slide_" + a).css({
        "display": "list-item"
    });
    var b = $("#panel").find("#slide_" + a).find("a:first").attr("href"), c = $("#panel").find("#slide_" + a).find("a:first").attr("title");
    $("#slide_text").html('<a href="' + b + '" target="_blank" title="' + c + '" rel="nofollow">' + c + "</a>"), $("#slide_bg").height($("#slide_text").height());
}

function init_lazyload() {
    $(".conBox img").lazyload();
}

function getStrLength(b) {
    var a = b.replace(/[^\x00-\xff]/g, "**");
    return a.length;
}

function WidthCheck(d, f) {
    var a = 0;
    for (var b = 0; b < d.length; b++) {
        var e = d.charCodeAt(b);
        e >= 1 && e <= 126 || 65376 <= e && e <= 65439 ? a++ : a += 2;
    }
    return a > f ? !1 : !0;
}

function strlen(c) {
    var a = 0, d = "utf-8";
    for (var b = 0; b < c.length; b++) a += c.charCodeAt(b) < 0 || c.charCodeAt(b) > 255 ? d == "utf-8" ? 3 : 2 : 1;
    return a;
}

function get_cookie_rating_id(b) {
    var a = getCookie("rated_" + b);
    a != "" && a != null && jQuery("#post-ratings-" + b).find("a").removeAttr("href").addClass("noLine");
}

function post_ratings_handle(b) {
    var a = getCookie("rated_" + b);
    a != "" && a != null && jQuery("#post-ratings-" + b).find("a").removeAttr("href").addClass("noLine");
}

function excerpt_handle(a) {
    $first_p = $("#content_" + a + " .p_excerpt"), getStrLength($first_p.text()) < 436 && ($next_html = $first_p.next(".p_detail").html(), $next_html != null && $next_html.toLowerCase().indexOf("<img") < 0 && $next_html.toLowerCase().indexOf("<blockquote") < 0 && $first_p.append($("<p class='my_add_text' style='padding: 0px; margin: 20px 0px 0px; display: block;'></p>").html($next_html)));
}

function get_uinfo(a) {
    var b = Date.parse(new Date);
    return b /= 1e3, $.getJSON(a + "/wp-header-xiaoxi.php?jsoncallback=?", {
        "nowtime": b
    }, function(c) {
        "ok" == c.status ? ($("#userinfor").html(c.message), $("#userinfor").css("display", ""), $(".topLoginBox").css("display", "none")) : "no" == c.status && ($("#userinfor").css("display", "none"), $(".topLoginBox").css("display", ""));
    }), !1;
}

function get_add_collection(post_id, type, num) {
	var usercollection="http://www.zdmya.com/user/collection.html";
    $.ajax({
        "type": "GET",
        "url": "/collection/save.html",
        "data": "post_id=" + post_id +"&type=" + type,
        "success": function(d) {
            clearTimeout(timeout_obj), 
            $("#collect_ul").html(""), 
            d == "nologin" ? ($('<li class="collectSuccess">您尚未登录,请登录后收藏</li>').appendTo("#collect_ul"), 
            $('<li><a href="javascript:ajax_login();">去登录</a></li>').appendTo("#collect_ul"), 
            $("#collect_div").attr("class", "collect_div_cancel"), 
            setTimeout("show()", 100), 
            timeout_obj = setTimeout("$('#collect_div').fadeOut(1000)", 3e3)) : d == "error" ? ($('<li class="collectSuccess">收藏过本文出错</li>').appendTo("#collect_ul"), 
	            $('<li><a href="' + usercollection + '"  target="_blank">去我的收藏夹</a></li>').appendTo("#collect_ul"), 
	            $("#collect_div").attr("class", "collect_div_cancel"), 
	            setTimeout("show()", 100), 
	            timeout_obj = setTimeout("$('#collect_div').fadeOut(1000)", 3e3)) : d == "exists" ? ($('<li class="collectSuccess">您已经收藏过本文</li>').appendTo("#collect_ul"), 
	            		$('<li><a href="' + usercollection + '"  target="_blank">去我的收藏夹</a></li>').appendTo("#collect_ul"), 
	            		$("#collect_div").attr("class", "collect_div_cancel"), 
	            		setTimeout("show()", 100), 
	            		timeout_obj = setTimeout("$('#collect_div').fadeOut(1000)", 3e3)) : ($("#post_collect_" + post_id).html(parseInt(num)+1), 
	            				$('<li class="collectSuccess">收藏成功</li>').appendTo("#collect_ul"), 
	            				$('<li><a href="' + usercollection + '"  target="_blank">去我的收藏夹</a></li>').appendTo("#collect_ul"), 
	            				$("#collect_div").attr("class", "collect_div"), setTimeout("show()", 100), 
	            				timeout_obj = setTimeout("$('#collect_div').fadeOut(1000)", 3e3));
        }
    });
}

function show() {
    var a = document.getElementById("collect_div");
    a.style.display = "", setTimeout(function() {
        EX.addEvent.call(document, "click", hide);
    });
}

function hide() {
    var a = document.getElementById("collect_div");
    a.style.display = "none", EX.removeEvent.call(document, "click", hide);
}

function showC() {
    var a = document.getElementById("go_login_comment_div");
    a.style.display = "", setTimeout(function() {
        EX.addEvent.call(document, "click", hideC);
    });
}

function hideC() {
    var a = document.getElementById("go_login_comment_div");
    a.style.display = "none", EX.removeEvent.call(document, "click", hideC);
}

function leftMenu() {
    $(".leftTjlbBox").find(".current-menu-item a").addClass("selected"), $(".leftTjlbBox .current-menu-parent").find("a:first").addClass("selected"), $(".leftTjlbBox .sub-menu").find("a:last").addClass("selected"), $(".leftTjlbBox li").mouseover(function() {
        $(this).find(".sub-menu").css("visibility", "visible");
    }), $(".leftTjlbBox li").mouseout(function() {
        $(this).find(".sub-menu").css("visibility", "hidden");
    });
}

function wp_love_faxian_widget() {
    $mytest = $(".faxian_widget"), $(".faxian_widget ul li img").bind("mouseover", function() {
        clearTimeout($mytest.data("showTimeoutId"));
        if ($(this).attr("id") == "see_more") return !1;
        var a = $(this).parent("a").attr("href");
        return $this_faxian_widget = $(this).parent("a").parent("li").parent("ul").parent(".faxian_widget"), $this_faxian_widget.find(".faxian_widget_img").attr("height", $(this).attr("tmp_height")).attr("width", $(this).attr("tmp_width")).attr("style", $(this).attr("tmp_style")).attr("src", $(this).attr("src")), $this_faxian_widget.find(".faxian_widget_title").html('<a href="' + a + "\" target=\"_blank\">" + $(this).attr("title") + "</a>"), $this_faxian_widget.find(".faxian_href").attr("href", a), $mytest.data("showTimeoutId", setTimeout("$this_faxian_widget.children('.full').fadeIn('slow').css('position', 'absolute')", 500)), !1;
    }), $(".faxian_widget ul li .relateFxPic").bind("mouseover", function() {
        clearTimeout($mytest.data("showTimeoutId"));
    }), $(".full").mouseleave(function() {
        $(".full").fadeOut("fast");
    }), $(".faxian_widget").mouseleave(function() {
        clearTimeout($mytest.data("showTimeoutId")), $(".full").fadeOut("fast");
    });
}

function scrollToPosition(b) {
    var a = $("#" + b).position().top;
    return $(window).scrollTop(a - 25), !1;
}

function siteNav_mouseover() {
    $site_nav = $("#siteNav"), $site_nav.find(".subSiteNav").css("visibility", "visible"), $site_nav.addClass("siteNavBlockHover");
}

function siteNav_mouseout() {
    $site_nav = $("#siteNav"), $site_nav.find(".subSiteNav").css("visibility", "hidden"), $site_nav.removeClass("siteNavBlockHover");
}

function submitBox_mouseover() {
    $site_nav = $("#submitBox"), $site_nav.find(".subSubmitBox").css("visibility", "visible"), $site_nav.addClass("submitBoxHover");
}

function submitBox_mouseout() {
    $site_nav = $("#submitBox"), $site_nav.find(".subSubmitBox").css("visibility", "hidden"), $site_nav.removeClass("submitBoxHover");
}

function nickname_mouseover() {
    $nick_name = $("#nick_name"), $nick_name.find(".subNickNameBox").css("visibility", "visible"), $nick_name.addClass("nickNameBoxHover");
}

function nickname_mouseout() {
    $nick_name = $("#nick_name"), $nick_name.find(".subNickNameBox").css("visibility", "hidden"), $nick_name.removeClass("nickNameBoxHover");
}

function loginLink_mouseover() {
    $nick_name = $("#loginLink"), $nick_name.find(".subLogin").css("visibility", "visible"), $nick_name.addClass("loginLinkHover");
}

function loginLink_mouseout() {
    $nick_name = $("#loginLink"), $nick_name.find(".subLogin").css("visibility", "hidden"), $nick_name.removeClass("loginLinkHover");
}

var thisLeftClass = "";

jQuery(function() {
    var g = navigator.userAgent.toLowerCase(), m = {
        "IE": /msie/.test(g),
        "OPERA": /opera/.test(g),
        "MOZ": /gecko/.test(g),
        "IE5": /msie 5 /.test(g),
        "IE55": /msie 5.5/.test(g),
        "IE6": /msie 6/.test(g),
        "IE7": /msie 7/.test(g),
        "SAFARI": /safari/.test(g)
    };
    jQuery(".toTop").click(function() {
        jQuery("html, body").animate({
            "scrollTop": 0
        }, 150);
    }), m.IE6 && jQuery("#header_top").css("position", "relative").css("top", 0);
    var b = jQuery("#right_side").height(), e = $("#right_sliding"), j = e.length > 0, l = 0, c = 0, k = $("#footer").height(), n = jQuery(window).height(), h = !1, d = !1, a = !1;
    j && (l = e.position().top, c = e.height());
    var f = $(".leftLikeBox");
    f && (f.css({
        "top": Math.ceil(n / 2) + "px"
    }), f.css({
        "left": Math.ceil((document.documentElement.clientWidth - 1e3) / 2) + -77 + "px"
    }), f.css("display", "block")), slidingFunction = function() {
        var t = document.body.scrollTop || document.documentElement.scrollTop;
        t > 300 ? jQuery("#backToTop").show() : jQuery("#backToTop").hide(), m.IE6 && jQuery("#backToTop").css("top", t + n - 166);
        var v = jQuery("body").height(), r = document.getElementById("backToTop");
        if (r) {
            r.style.right = (document.documentElement.clientWidth - 1e3) / 2 + -25 + "px";
            var q = $("#backToTop").height();
            if (v <= t + n + k - q + 50) {
                var u = t + n + k + 25 - v;
                $("#backToTop").css({
                    "position": "fixed",
                    "bottom": u
                });
            } else $("#backToTop").css({
                "position": "fixed",
                "bottom": 80
            });
        }
        if (j) {
            var s = jQuery("#left_side").height();
            if (s < b + 300) return;
            if (t > l - 50) {
                if (window.XMLHttpRequest) if (v <= t + c + k + 50) {
                    if (!a) {
                        h = !1, d = !1, a = !0;
                        var u = v - c - k - 20;
                        e.css({
                            "position": "absolute",
                            "top": u
                        });
                    }
                } else h || (e.css({
                    "position": "fixed",
                    "top": 40
                }), h = !0, d = !1, a = !1);
            } else d || (e.css({
                "position": "relative",
                "top": 0
            }), d = !0, h = !1, a = !1);
        }
        if (f) {
            var o = $(".leftLikeBox").height(), u = t + n + k + 100 - v;
            u = n - u;
            var p = Math.ceil(n / 2);
            v <= t + n + k - o + 50 + 120 - p ? f.css({
                "top": u + "px"
            }) : f.css({
                "top": p + "px"
            });
        }
    }, jQuery(window).bind("scroll", slidingFunction), jQuery(window).bind("resize", slidingFunction), slidingFunction(), $(".nav ul li").find(".linkMenu").each(function() {
        $(this).attr("default") == "current" && $(this).addClass("currentMenu");
    }), $(".nav ul li").mouseover(function() {
        $(this).find(".sub2").css("visibility", "visible"), $(this).children("a.linkMenu").addClass("hoverMenu");
    }), $(".nav ul li").mouseout(function() {
        $(this).find(".sub2").css("visibility", "hidden"), $(this).find(".linkMenu").attr("default") == "current" ? $(this).children("a").removeClass("hoverMenu") : $(this).children("a").not("#currentMenu").removeClass("hoverMenu");
    }), $(".loginBtn").mouseover(function() {
        $(this).find(".loginSub").css("visibility", "visible"), $(this).children("a.loginButton").addClass("hoverLogin");
    }), $(".loginBtn").mouseout(function() {
        $(this).find(".loginSub").css("visibility", "hidden"), $(this).children("a.loginButton").removeClass("hoverLogin");
    }), $(".discussBox").mouseover(function() {
        $(this).find(".sub-menu").css("visibility", "visible"), $(this).addClass("discussHover");
    }), $(".discussBox").mouseout(function() {
        $(this).find(".sub-menu").css("visibility", "hidden"), $(this).removeClass("discussHover");
    }), $("a.xhBtn").mouseover(function() {
        $(this).find(".spanNum").css("display", "none"), $(this).find(".spanWord").css("display", "block");
    }), $("a.xhBtn").mouseout(function() {
        $(this).find(".spanWord").css("display", "none"), $(this).find(".spanNum").css("display", "block");
    }), $("a.xhBtnCurrent").mouseover(function() {
        $(this).find(".spanNum").css("display", "none"), $(this).find(".spanWord").css("display", "block");
    }), $("a.xhBtnCurrent").mouseout(function() {
        $(this).find(".spanWord").css("display", "none"), $(this).find(".spanNum").css("display", "block");
    }), $("a.scBtn").mouseover(function() {
        $(this).find(".spanNum").css("display", "none"), $(this).find(".spanWord").css("display", "block");
    }), $("a.scBtn").mouseout(function() {
        $(this).find(".spanWord").css("display", "none"), $(this).find(".spanNum").css("display", "block");
    }), $("a.scBtnCurrent").mouseover(function() {
        $(this).find(".spanNum").css("display", "none"), $(this).find(".spanWord").css("display", "block");
    }), $("a.scBtnCurrent").mouseout(function() {
        $(this).find(".spanWord").css("display", "none"), $(this).find(".spanNum").css("display", "block");
    }), $("ul#widget_coupon_title li.hotCoupon").mouseover(function() {
        jQuery("#hot_coupon .current_coupon").size() < 1 && jQuery("#hot_coupon>li").eq(0).removeClass().addClass("current_coupon"), jQuery("#hot_coupon").show(), $("#widget_coupon_title").removeClass("hotCouponBox").addClass("newCouponBox"), jQuery("#new_coupon").hide();
    }), $("ul#widget_coupon_title li.newCoupon").mouseover(function() {
        jQuery("#new_coupon .current_coupon").size() < 1 && jQuery("#new_coupon>li").eq(0).removeClass().addClass("current_coupon"), jQuery("#new_coupon").show(), $("#widget_coupon_title").removeClass("newCouponBox").addClass("hotCouponBox"), jQuery("#hot_coupon").hide();
    }), jQuery(".coupon_list>li").mouseover(function() {
        var o = jQuery(this).attr("class");
        o.indexOf("other_coupon") >= 0 && (jQuery(".current_coupon").removeClass().addClass("other_coupon"), jQuery(this).removeClass().addClass("current_coupon"));
    }), jQuery(".couponPicBox").mouseover(function() {
        jQuery(this).children("div").children("a").addClass("get_coupon_hover");
    }).mouseout(function() {
        jQuery(this).children("div").children("a").removeClass("get_coupon_hover");
    }), $(".back_button").click(function() {
        if (document.referrer.indexOf("zdmya.com") > 0) return window.history.go(-1), !1;
        window.location.href = "/";
    }), $(".comment-quote-link").click(function() {
        if ($("#login_user_id").val() <= 0) return showC(), !1;
        if ($("#comment").length > 0) {
            var r = $(this).attr("title"), q = $(this).parent().attr("id");
            q = q.split("_")[1];
            var p = $("#comment").val();
            if (p.length > 0 && p != "") {
                var o = p.substr(p.length - 1, 1);
                o != "\n" && (p += "\n");
            }
            $("#comment").val(p), $("#comment").focus(), $("#comment_parent").attr("value", q);
            var s = document.getElementById("cdc_quote_to");
            return s && s.parentNode.removeChild(s), $("#commentform").before('<div id="cdc_quote_to" style="margin: 0.5em 0px 0.5em 17px;">引用“' + $(this).attr("title") + '”：<a class="comment_lint" href="javascript:;" title="取消引用" onclick="cancle_quote()">取消引用</a></div>'), !1;
        }
    }), $(".comment-reply-link").click(function() {
        if ($("#login_user_id").val() <= 0) return showC(), !1;
        if ($("#comment").length > 0) {
            var r = $(this).attr("title"), p = $.trim($("#comment").val());
            if (p == "为维护良好的讨论环境，请勿在留言中发布政治话题、买卖返券、加价转让、人身攻击等内容。") p = r + " "; else {
                var q = p.split(" "), o = !0;
                for (i = 0; i < q.length; i++) if (r == q[i]) {
                    o = !1;
                    break;
                }
                o ? p = r + " " + p + " " : p += " ";
            }
            return $("#comment").focus(), $("#comment").val(p), !1;
        }
    }), $(".open").click(function() {
        $("dd.openClose").css("height", "auto"), $(this).css("display", "none"), $(".close").css("display", "block");
    }), $(".close").click(function() {
        $("dd.openClose").height(52), $(this).css("display", "none"), $(".open").css("display", "block");
    }), jQuery(".post_list>li").mouseover(function() {
        var o = jQuery(this).attr("class");
        o.indexOf("other_post") >= 0 && (jQuery(".current_post").removeClass().addClass("other_post"), jQuery(this).removeClass().addClass("current_post"));
    }), jQuery(".post_list>li").mouseout(function() {
        var o = jQuery(this).attr("class");
        o.indexOf("current_post") >= 0 && jQuery(this).removeClass().addClass("current_post");
    }), jQuery(".double_eleven_hot .post_list>li").mouseover(function() {
        var o = jQuery(this).attr("class");
        o.indexOf("other_post") >= 0 && (jQuery(".double_eleven_hot .current_post").removeClass().addClass("other_post"), jQuery(this).removeClass().addClass("current_post"));
    }), jQuery(".double_eleven_hot .post_list>li").mouseout(function() {
        var o = jQuery(this).attr("class");
        o.indexOf("current_post") >= 0 && jQuery(this).removeClass().addClass("current_post");
    }), $("#guideBox").click(function() {
        hide_landingpage();
    }), $("#hide_href1").click(function() {
        hide_landingpage();
    }), $("#hide_href2").click(function() {
        hide_landingpage();
    });
}), $(document).ready(function() {
    $(".inpu1").click(function() {
        $(this).parent("form.search").addClass("searchHover"), $(this).parent("form.search").children(".inpu2").addClass("btnHover");
    }), $(".inpu1").blur(function() {
        $(this).parent("form.search").removeClass("searchHover"), $(this).parent("form.search").children(".inpu2").removeClass("btnHover");
    }), init_lazyload(), $("#rank_title_id").mouseover(function() {
        $("#widget_user_title").removeClass().addClass("newUserBox");
    }), $("#prestige_title_id").mouseover(function() {
        $("#widget_user_title").removeClass().addClass("hotUserBox");
    }), $("#rank_title_id").mouseover(function() {
        $("#prestige_div").css("display", "block"), $("#rank_div").css("display", "none");
    }), $("#prestige_title_id").mouseover(function() {
        $("#prestige_div").css("display", "none"), $("#rank_div").css("display", "block");
    }), document.getElementById("collect_div") && (document.getElementById("collect_div").onclick = EX.stop);
});

var timeout_obj;

String.prototype.Trim = function() {
    return this.replace(/(^\s*)|(\s*$)/g, "");
}, String.prototype.LTrim = function() {
    return this.replace(/(^\s*)/g, "");
}, String.prototype.RTrim = function() {
    return this.replace(/(\s*$)/g, "");
};

var EX = {
    "addEvent": function(b, a) {
        var c = this;
        c.addEventListener ? c.addEventListener(b, a, !1) : c.attachEvent ? c.attachEvent("on" + b, a) : c["on" + b] = a;
    },
    "removeEvent": function(b, a) {
        var c = this;
        c.removeEventListener ? c.removeEventListener(b, a, !1) : c.detachEvent ? c.detachEvent("on" + b, a) : c["on" + b] = null;
    },
    "stop": function(a) {
        a = a || window.event, a.stopPropagation ? a.stopPropagation() : a.cancelBubble = !0;
    }
};

function ajax_filteruser(form) {
	var username = form.username.value;
	var password = form.pwd.value;
	if(username==''){
		$("#loginmsg").text("用户名不能为空!");
		return false;
	}
	if(password==''){
		$("#loginmsg").text("密码不能为空!");
		return false;
	}
	$.ajax({
        "type": "GET",
        "url": "/login.html?username=" + username + "&password=" + password,
        "data": "",
        "dataType": "json",
        "success": function(result) {
            if(result.result=='ok'){
            	window._loginbox.hide();
            	setuserinfo(result.username,result.usergrade);
            }else{
            	$("#loginmsg").text("用户名或密码错误!");
            }
        }
    });
}

function setuserinfo(username,usergrade){
	//隐藏登录框
	$("#topLoginBox").css('display','none');	
	//显示用户名
	$("#userinfor").css('display','');
	
	$("#message_nologin").css('display','none');
	$("#message_login").css('display','');
	
	$("#username").text(username);
	$("#usergrade").html("L"+usergrade+"<div class=\"gradeRight\"></div>");
}

$(function(){
	$.ajax({
        "type": "GET",
        "url": "/getuser.html",
        "data": "",
        "dataType": "json",
        "success": function(result) {
            if(result.result=='ok'){
            	setuserinfo(result.username,result.usergrade);
            }
        }
    });
});	

function stoppropagation(a) {
    $.browser.msie ? event.cancelBubble = !0 : (a.stopPropagation(), a.preventDefault());
}

function ajax_login() {
    var html = "";
    html += '    <div class="loginBg"></div>', 
    html += '    <form class="loginWrap"  id="ajaxLoginForm">', 
    html += '        <div class="loginHeader">', 
    html += '            <span class="loginTopTitle">登录</span>', 
    html += '            <a href="#" class="closeCorner">关闭</a>', 
    html += '            <div class="loginReg">没有账号？<a href="/register.html">快速注册</a></div>', 
    html += '            <div class="clear"></div>', 
    html += "        </div>", 
    html += '        <div id="loginMsg" >', 
    html += "        </div>", 
    html += '        <div class="perDataItem">', 
    html += '            <label for="userLogin">用户名：</label>', 
    html += '            <input type="text" name="username" id="userLogin" class="inputData" tabindex="100"/>', 
    html += "        </div>", 
    html += '        <div class="perDataItem">', 
    html += '            <label for="userPass">密码：</label>', 
    html += '            <input type="password" name="pwd" id="userPass" class="inputData" tabindex="101"/>', 
    html += "        </div>",
    html += '        <div class="loginBtnBox">', 
    html += '            <input type="button" id="ajax-submit" name="ajax-submit" class="loginBtn" value="登&nbsp;&nbsp;录" onclick="ajax_filteruser(this.form);" tabindex="105"/>', 
    html += '            <span id="loginmsg"></span>', 
    html += "        </div>",
	html += "    </form>", 
	
		window._loginbox || (window._loginbox = $('<div class="loginBox"></div>'), 
		$(document.body).append(window._loginbox), window._loginbox.html(html), $(document).on("keydown", function(b) {        
		b.keyCode == 13 && (stoppropagation(b), _fml = $("#ajaxLoginForm"), ajax_filteruser(_fml[0]));
    })), window._loginbox.show(), $("#userLogin").focus(), jQuery("html, body").animate({
        "scrollTop": 0
    }, 0), $(".closeCorner").off("click").on("click", function() {
        window._loginbox.hide();
    });
}


function checkusername(){
	var username = $("#regusername").val();
	if(username==null || username==''){
		$("#usernamemsg").text("用户名不能为空！");
		return false;
	}
	$.ajax({
        "type": "GET",
        "url": "/checkusername.html?username=" + username,
        "data": "",
        "dataType": "json",
        "success": function(result) {
        	if(result.result=='no'){
        		$("#usernamemsg").text("该名称太火爆已经被抢注！");
        	}else{
        		$("#usernamemsg").text("用户名可用！");
        	}
        }
    });
	return true;
}

function checkemail(){
	var email = $("#user_email").val();
	if(email==null || email==''){
		$("#emailmsg").text("邮箱不能为空！");
		return false;
	}
	var emailreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
	if(!emailreg.test(email)){
		$("#emailmsg").text("邮箱格式不正确！");
		return false;
	}
	$.ajax({
        "type": "GET",
        "url": "/checkemail.html?email=" + email,
        "data": "",
        "dataType": "json",
        "success": function(result) {
        	if(result.result=='no'){
        		$("#emailmsg").text("该邮箱已经注册过！");
        	}else{
        		$("#emailmsg").text("邮箱可用！");
        	}
        }
    });	
	return true;
}

function checkpassword1(){
	var user_pwd1=$("#user_pwd1").val();
	var user_pwd2=$("#user_pwd2").val();
	if(user_pwd1==''){
		$("#user_pwd1_msg").text("密码不能为空！");
		return false;
	}
	if(user_pwd1.length<6){
		$("#user_pwd1_msg").text("密码至少6位！");
		return false;
	}
	if(user_pwd2!='' && user_pwd1!=user_pwd2){
		$("#user_pwd1_msg").text("密码不相等！");
		return false;
	}
	$("#user_pwd1_msg").text("密码可用！");
	return true;
}

function checkpassword2(){
	var user_pwd1=$("#user_pwd1").val();
	var user_pwd2=$("#user_pwd2").val();
	if(user_pwd2==''){
		$("#user_pwd2_msg").text("密码不能为空！");
		return false;
	}
	if(user_pwd1!=user_pwd2){
		$("#user_pwd2_msg").text("密码不相等！");
		return false;
	}
	if(user_pwd2.length<6){
		$("#user_pwd2_msg").text("密码至少6位！");
		return false;
	}
	checkpassword1()
	$("#user_pwd2_msg").text("密码可用！");
	return true;
}

function checkcheckcode(){
	var checkcode = $("#checkcode").val();
	if(checkcode==''){
		$("#checkcodemsg").text("验证码不能为空！");
		return false;
	}
	return true;
}

function logout(){
	location.href="http://www.zdmya.com/logout.html";
}

function submitreg(){
	if(checkusername()&&checkemail()&&checkpassword1()&&checkpassword2()&&checkcheckcode()){
		$("#registerform").submit();
	}
}

function MarqueeNews() {
    $("#news").find("ul").animate({
        "marginTop": "-20px"
    }, 1e3, function() {
        $(this).css({
            "marginTop": "0px"
        }).find("li:first").appendTo(this);
    });
}

function gstop() {
    clearInterval(MarNews);
}

function gstart() {
    MarNews = setInterval(MarqueeNews, 3e3);
}

function goup() {
    $("#news").find("ul li").last().insertBefore($("#news").find("ul li").first()), $("#news").find("ul").css({
        "marginTop": "-20px"
    }), $("#news").find("ul").animate({
        "marginTop": "0px"
    }, 500);
}

function godown() {
    $("#news").find("ul").animate({
        "marginTop": "-20px"
    }, 500, function() {
        $(this).css({
            "marginTop": "0px"
        }).find("li:first").appendTo(this);
    });
}

var MarNews = setInterval(MarqueeNews, 3e3), is_am = 0, domain_host = "http://" + window.location.host, admin_host = "http://www.zdmya.com";

